-
-
Notifications
You must be signed in to change notification settings - Fork 248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: add an async dhcp client #1250
base: master
Are you sure you want to change the base?
Conversation
CLIENT_SYSTEM_ARCHITECTURE_TYPE = 93 # Client System Architecture Type | ||
CLIENT_NETWORK_INTERFACE_IDENTIFIER = 94 # Client Network Interface Identifier | ||
CLASSLESS_STATIC_ROUTE = 121 | ||
DOMAIN_SEARCH = 119 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this one is not sorted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i added it because at some point it was missing when i was testing something, but this is still a draft, these are not even used at this point
Wow, c'est magnifique. It will take some time to read & digest, be patient :) |
Thanks ! Take your time, it's still a draft and lots of things are going to change, i'm not yet proud with everything |
12c5eb9
to
14cdae0
Compare
# bring up the socket | ||
socket.__init__(self, AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)) | ||
socket.setblocking(self, False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@etene what would you say — could it be a reasonable idea to make a socket wrapper that would use composition, and proxy most of the properties, but fake .type
to make it work with loop.create_datagram_endpoint()
? and then use asyncio.Protocol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's an interesting idea.
I have tried at some point to make raw sockets work with asyncio.Protocol
but changed my mind when i saw how a lot of code assumed TCP, UDP or Unix sockets iirc. But I hadn't thought about faking the socket type, and it might just work given how similar raw & UDP sockets are.
I'm willing to try if I find the time to. However, the python stdlib code might be too tightly coupled with UDP/TCP/unix sockets, so it might turn out to be dirty or impossible without making a PR to python itself, which is a whole other can of worms...
14cdae0
to
353efde
Compare
@etene JFYI: I plan to keep Python compatibility back to version 3.9 as for now. Will be there any issues with that — pls let me know. |
@svinota I'm pretty sure i can make it work with 3.9 upwards, my initial draft was based on 3.12 out of habit and comfort but the really important asyncio parts have been there since 3.7. |
The reason behind 3.9 (FIXME: I should document it) is |
f9376db
to
e0566b0
Compare
31c1b42
to
d6fa1e5
Compare
d6fa1e5
to
417a8d9
Compare
@etene regarding the tests I would propose this thing:
[1] pyroute2/tests/test_core/test_ipr/test_route_dump_async.py Lines 7 to 23 in 899fc58
[2] pyroute2/pyroute2/netlink/rtnl/iprsocket.py Lines 93 to 95 in 899fc58
[3] pyroute2/docs/iproute_linux.rst Lines 3 to 11 in 19a309b
[4] source: pyroute2/pyroute2/iproute/linux.py Lines 254 to 267 in 19a309b
[5] rendered: https://pyroute2.org/pyroute2-0.8.1-109-g19a309be/iproute_linux.html#pyroute2.iproute.linux.RTNL_API.filter_messages |
def get_cmdline_options(self) -> tuple[str]: | ||
'''All commandline options passed to udhcpd.''' | ||
return ( | ||
'udhcpd', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use busybox udhcpd
instead, on Fedora there is no separate link for that, unlike Ubuntu; but running the plugin this way as busybox udhcpd
works on both Fedora and Ubuntu.
Here is my async DHCP client implementation, still a work in progress
closes #1243